home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / UNIXTOOL / MEMACS / H / Estruct < prev    next >
Text File  |  1990-06-26  |  28KB  |  951 lines

  1. /*    ESTRUCT:    Structure and preprocesser defined for
  2.             MicroEMACS 3.10
  3.  
  4.             written by Daniel Lawrence
  5.             based on code by Dave G. Conroy,
  6.                 Steve Wilhite and George Jones
  7. */
  8.  
  9. #ifdef    LATTICE
  10. #undef    LATTICE      /* don't use their definitions...use ours     */
  11. #endif
  12. #ifdef    MSDOS
  13. #undef    MSDOS
  14. #endif
  15. #ifdef    AMIGA
  16. #undef    AMIGA
  17. #endif
  18. #ifdef    EGA
  19. #undef    EGA
  20. #endif
  21. #ifdef    CTRLZ
  22. #undef    CTRLZ
  23. #endif
  24. #ifdef    ARM
  25. #undef    ARM
  26. #endif
  27.  
  28. /*    Program Identification.....
  29.  
  30.     PROGNAME should always be MicroEMACS for a distribution
  31.     unmodified version. People using MicroEMACS as a shell
  32.     for other products should change this to reflect their
  33.     product. Macros can query this via the $progname variable
  34. */
  35.  
  36. #define PROGNAME    "MicroEMACS"
  37. #define    VERSION        "3.11 BETA"
  38.  
  39. /*    Machine/OS definitions            */
  40. /*    [Set one of these!!]            */
  41.  
  42. #define AMIGA    0            /* AmigaDOS            */
  43. #define AOSVS    0            /* Data General AOS/VS        */
  44. #define AVIION    0            /* Data General AViiON        */
  45. #define BSD    0            /* UNIX BSD 4.2 and ULTRIX    */
  46. #define FINDER    0            /* Macintosh OS         */
  47. #define HPUX    0            /* HPUX HP 9000 minicomputer    */
  48. #define MPE    0            /* HP MPE/XL            */
  49. #define MSDOS    0            /* MS-DOS            */
  50. #define OS2    0            /* Microsoft or IBM OS/2    */
  51. #define RISCOS    1            /* Acorn Archimedes RISC OS    */
  52. #define SMOS    0            /* Supermax UNIX System V    */
  53. #define ST520    0            /* ST520, TOS            */
  54. #define SUN    0            /* SUN v4.0            */
  55. #define USG    0            /* UNIX system V        */
  56. #define V7    0            /* V7 UNIX or Coherent or BSD4.2*/ 
  57. #define VMS    0            /* VAX/VMS            */
  58. #define WMCS    0            /* Wicat's MCS            */
  59. #define XENIX    0            /* IBM-PC SCO XENIX        */
  60.  
  61. /*    Compiler definitions            */
  62. /*    [Set one of these!!]            */
  63. #define    ALCYON    0    /* ALCYON Atari ST compiler */ 
  64. #define    ARM    1    /* Acorn ARM C for the Archimedes */
  65. #define    DGC    0    /* Data General AOS/VS C... */
  66. #define AZTEC    0    /* Aztec C 3.20e */
  67. #define DTL    0    /* DataLight C v3.12 */
  68. #define GCC    0    /* the GNU C compiler */
  69. #define LATTICE 0    /* Lattice 2.14 through 3.0 compilers */
  70. #define MSC    0    /* MicroSoft C compile version 3 & 4 & 5.1 */
  71. #define MWC    0    /* Mark Williams C */
  72. #define TURBO    0    /* Turbo C/MSDOS */
  73. #define UNIX    0    /* a standard UNIX compiler (cc) */
  74.  
  75. /*      Machine stack growth direction.                     */
  76. /*  [Set this to 1 if your machine stack grows UP!!!]       */
  77. /*      data general mv/eclipse series stack grows up.      */
  78. /*      dec vax series stack grows down... got it???        */
  79.  
  80. #define STACK_GROWS_UP  0
  81.  
  82. /*    Debugging options    */
  83. #define    RAMSIZE    0    /* dynamic RAM memory usage tracking */
  84. #define    RAMSHOW    0    /* auto dynamic RAM reporting */
  85. #define    RAMTRCK    0    /* send debug info to MALLOC.DAT */
  86.  
  87. /*   Special keyboard/network definitions         */
  88.  
  89. #define WANGPC    0        /* WangPC - mostly escape sequences    */
  90. #define VT100    0        /* Handle VT100 style keypad.    */
  91. #define KEYPAD    0        /* (VMS) - turn on application keypad */
  92. #define XONDATA    0        /* VMS only - set to force /NOTTSYNC/NOHOSTSY */
  93. #define    RMSIO    0        /* on VMS, skip the rotten C runtime      */
  94.                 /* and use RMS directly            */
  95. #define OPTMEM    0        /* on VMS 5.0 and up, use a less standard*/
  96.                 /* but more efficient memory allocator    */
  97. #define    NOVELL    0        /* IBMPC Novell NetWare flag! */
  98.  
  99. /*    Terminal Output definitions        */
  100. /*    [Set one of these!!]            */
  101.  
  102. #define    ACORN    1            /* Acorn Archimedes VDU drivers    */
  103. #define ANSI    0            /* ANSI escape sequences    */
  104. #define ATARI    0            /* Atari 520/1040ST screen    */
  105. #define DASHER    0            /* DG Dasher 2xx/4xx crts    */
  106. #define DG10    0            /* Data General system/10    */
  107. #define FMR    0            /* Fujitsu FMR series driver    */
  108. #define HP110    0            /* HP110 screen driver        */
  109. #define HP150    0            /* HP150 screen driver        */
  110. #define IBMPC    0            /* IBM-PC CGA/MONO/EGA/VGA drvr    */
  111. #define MAC    0            /* Macintosh            */
  112. #define NEC    0            /* NEC-9801VM driver        */
  113. #define OS2NPM    0            /* OS/2 non-Presentation Mgr.    */
  114. #define RAINBOW 0            /* Use Rainbow fast video.    */
  115. #define SMG    0            /* SMG library on VMS        */
  116. #define TERMCAP 0            /* Use TERMCAP            */
  117. #define TIPC    0            /* TI Profesional PC driver    */
  118. #define VT52    0            /* VT52 terminal (Zenith).    */
  119. #define Z309    0            /* Zenith 100 PC family    driver    */
  120.  
  121. /*    Language text options    (pick one)                */
  122.  
  123. #define ENGLISH 1
  124. #define    FRENCH    0
  125. #define    SPANISH    0
  126. #define    GERMAN    0
  127. #define    DUTCH    0
  128. #define PLATIN    0
  129. #define    JAPAN    0
  130.  
  131. /*    Configuration options    */
  132.  
  133. #define    TYPEAH    1    /* type ahead causes update to be skipped    */
  134. #define DEBUGM    1    /* $debug triggers macro debugging        */
  135. #define    LOGFLG    0    /* send all executed commands to EMACS.LOG    */
  136. #define    VISMAC    0    /* update display during keyboard macros    */
  137. #define    CTRLZ    0    /* add a ^Z at end of files under MSDOS only    */
  138. #define    CLEAN    0    /* de-alloc memory on exit            */
  139. #define    CALLED    0    /* is emacs a called subroutine? or stand alone */
  140.  
  141. #define REVSTA    1    /* Status line appears in reverse video     */
  142. #define    COLOR    1    /* color commands and windows            */
  143.  
  144. #define FILOCK    0    /* file locking under unix BSD 4.2        */
  145. #define    ISRCH    1    /* Incremental searches like ITS EMACS        */
  146. #define    FLABEL    1    /* function key label code [HP150]        */
  147. #define    CRYPT    1    /* file encryption enabled?            */
  148. #define MAGIC    1    /* include regular expression matching?        */
  149. #define MOUSE    0     /* Include routines for mouse actions        */
  150. #define    NOISY    1    /* Use a fancy BELL if it exists        */
  151. #define CTAGS    1    /* include vi-like tagging?            */
  152. #define    SPEECH    0    /* spoken EMACS, for the sight impared [not ready] */
  153. #define    VARARG    1    /* use varargs.h for mlwrite()            */
  154. #define    FTYPE    1    /* Maintain file types for buffers        */
  155.  
  156. /*    Character set options        */
  157. /*    [Set one of these!!]        */
  158. #define ASCII    1    /* always using ASCII char sequences for now    */
  159. #define EBCDIC    0    /* later IBM mainfraim versions will use EBCDIC    */
  160.  
  161. /* handle constant and voids properly */
  162.  
  163. #if    VMS
  164. #define    CONST    readonly
  165. #define    VOID    void
  166. #define NOSHARE noshare
  167. #else
  168. #if    AOSVS
  169. #define CONST $shared $align(1)     /* fake a  const */
  170. #define    VOID
  171. #define NOSHARE $low32k $align(1)   /* attempt to optimize read/write vars. */
  172. #else
  173. #ifdef    __STDC__
  174. #define    CONST    const
  175. #define    VOID    void
  176. #define    NOSHARE
  177. #else
  178. #define    CONST
  179. #define    VOID
  180. #define NOSHARE
  181. #endif
  182. #endif
  183. #endif
  184.  
  185. /* Unfortunately, while ARM C does support const, it will not allow implicit
  186.  * conversions of (const char *) to (char *). This is (in my opinion) correct,
  187.  * but it breaks a lot of code in Emacs. So, reluctantly, I have disabled
  188.  * the use of CONST.
  189.  */
  190. #if    ARM
  191. #undef    CONST
  192. #define    CONST
  193. #endif
  194.  
  195. /*    System dependant library redefinitions, structures and includes */
  196.  
  197. /*    the following define allows me to initialize unions...
  198.     otherwise we make them structures (like the keybinding table)  */
  199.  
  200. /*    multibyte character support?    */
  201.  
  202. #if    NEC || FMR
  203. #define    DBCS    1    /* double byte character sets enabled */
  204. #define    INSDEL    1    /* use insert/delete line display optimizations */
  205.  
  206. /* define DBCS prefix bytes */
  207. #define    is2char(ch) (((ch&0xff) >= 0x81 && (ch&0xff) <= 0x9f) || ((ch&0xff) >=0xe0 && (ch&0xff) <= 0xfc))
  208.  
  209. #else
  210. #define    DBCS    0
  211. #define    INSDEL    0
  212. #endif
  213.  
  214. /*    Prototypes in use?    */
  215.  
  216. #if    ARM || MSC || TURBO || DTL || VMS || GCC
  217. #define    PROTO    1
  218. #else
  219. #define    PROTO    0
  220. #endif
  221.  
  222. #if    __STDC__ && (GCC == 0)    /* if ANSI C compatible */
  223. #define    ETYPE    union
  224. #else
  225. #define    ETYPE    struct
  226. #endif
  227.  
  228. #if MSDOS & (TURBO | MSC)
  229. #define    NEAR
  230. #define    DNEAR
  231. #define    PASCAL pascal
  232. #define    CDECL cdecl
  233. #else
  234. #define NEAR
  235. #define    DNEAR
  236. #define    PASCAL
  237. #define    CDECL
  238. #endif
  239.  
  240. #if    TURBO
  241. #include      <dos.h>
  242. #include      <mem.h>
  243. #undef peek
  244. #undef poke
  245. #define       peek(a,b,c,d)   movedata(a,b,FP_SEG(c),FP_OFF(c),d)
  246. #define       poke(a,b,c,d)   movedata(FP_SEG(c),FP_OFF(c),a,b,d)
  247. #endif
  248.  
  249. #if    LATTICE & MSDOS
  250. /* you may have to remove this one definition with LATTICE version
  251.    3.2 and above                          */
  252. #define    unsigned
  253. #endif
  254.  
  255. #if    AZTEC
  256. #undef    putc
  257. #undef    getc
  258. #if    MSDOS
  259. #define    getc    a1getc
  260. #define    int86    sysint
  261. #define    intdos(a, b)    sysint(33, a, b)
  262. #define    inp    inportb
  263. #define    outp    outportb
  264. #else
  265. #define getc    agetc
  266. #endif
  267. #define putc    aputc
  268.  
  269. struct XREG {
  270.     unsigned ax,bx,cx,dx,si,di,ds,es;
  271. };
  272.  
  273. struct HREG {
  274.     char al,ah,bl,bh,cl,ch,dl,dh,d1,d2,e1,e2;
  275. };
  276.  
  277. union REGS {
  278.     struct XREG x;
  279.     struct HREG h;
  280. };
  281.  
  282. struct SREGS {
  283.     unsigned cs, ss, ds, es;
  284. };
  285. #endif
  286.  
  287. #if    MSDOS & DTL
  288. #include    <dos.h>
  289. #endif
  290.  
  291. #if    MSDOS & MWC
  292. #include    <dos.h>
  293. #define    int86(a, b, c)    intcall(b, c, a)
  294. #define    intdos(a, b)    intcall(a, b, DOSINT)
  295. #define    inp(a)        in(a)
  296. #define    outp(a, b)    out(a, b)
  297. #define    movmem(a, b, c)    memcpy(b, a, c)
  298.  
  299. struct XREG {
  300.     unsigned int ax,bx,cx,dx,si,di,ds,es,flags;
  301. };
  302.  
  303. struct HREG {
  304.     char al,ah,bl,bh,cl,ch,dl,dh;
  305.     unsigned int ds,es,flags;
  306. };
  307.  
  308. union REGS {
  309.     struct XREG x;
  310.     struct HREG h;
  311. };
  312. #endif
  313.  
  314. #if    MSDOS & MSC
  315. #include    <dos.h>
  316. #include    <memory.h>
  317. #define    peek(a,b,c,d)    movedata(a,b,FP_SEG(c),FP_OFF(c),d)
  318. #define    poke(a,b,c,d)    movedata(FP_SEG(c),FP_OFF(c),a,b,d)
  319. #define    movmem(a, b, c)        memcpy(b, a, c)
  320. #endif
  321.  
  322. #if    MSDOS & LATTICE
  323. #undef    CPM
  324. #undef    LATTICE
  325. #include    <dos.h>
  326. #undef    CPM
  327. #endif
  328.  
  329. /* this keeps VMS happy */
  330. #if    VMS
  331. #define    getname xgetname
  332. #define    unlink(a)    delete(a)
  333. #endif
  334.  
  335. /* For the Archimedes, use remove() */
  336. #if    ARM
  337. #define    unlink(a)    remove(a)
  338. #endif
  339.  
  340. /* some options for AOS/VS */
  341. #if     AOSVS
  342. #define ORMDNI  1
  343. #endif
  344.  
  345. /*    define some ability flags */
  346.  
  347. #if    IBMPC | Z309 | FMR
  348. #define    MEMMAP    1
  349. #else
  350. #define MEMMAP    0
  351. #endif
  352.  
  353. #if    MSDOS | OS2 | V7 | USG | SMOS | HPUX | BSD | (ST520 & MWC) | WMCS | SUN | MPE | RISCOS
  354. #define    ENVFUNC    1
  355. #else
  356. #define ENVFUNC 0
  357. #endif
  358.  
  359. /* Directory handling */
  360. #if    MPE
  361. #define DIRSEPSTR    "."
  362. #define DIRSEPCHAR    '.'
  363. #define    CURDIR        "@." /* Who knows??? */
  364. #else
  365. #if    ATARI || MSDOS || OS2
  366. #define    DIRSEPSTR    "\\"
  367. #define    DIRSEPCHAR    '\\'
  368. #define    CURDIR        ".\\"
  369. #else
  370. #if    RISCOS
  371. #define DIRSEPSTR    "."
  372. #define    DIRSEPCHAR    '.'
  373. #define CURDIR        ""
  374. #else
  375. #define DIRSEPSTR    "/"
  376. #define    DIRSEPCHAR    '/'
  377. #define CURDIR        "./"
  378. #endif
  379. #endif
  380. #endif
  381.  
  382. /* Default buffer type */
  383. #if    FTYPE
  384. #if    RISCOS
  385. #define    B_DEFTYPE    0xFFF
  386. #else
  387. #define    B_DEFTYPE    0 /* Or whatever */
  388. #endif
  389. #endif
  390.  
  391. /* Emacs startup, help, etc. file names */
  392.  
  393. #if    ST520 | FINDER | MSDOS | VMS | WMCS | AOSVS
  394. #define EMACSRC        "emacs.rc"        /* Startup file name    */
  395. #define EMACSHLP    "emacs.hlp"        /* Help file name    */
  396. #define EMACSLOG    "emacs.log"        /* Log file name    */
  397. #define ERRORCMD    "error.cmd"        /* Error command file    */
  398. #endif
  399.  
  400. #if    AMIGA | V7 | BSD | USG | SMOS | HPUX | XENIX
  401. #define EMACSRC        ".emacsrc"        /* Startup file name    */
  402. #define EMACSHLP    "emacs.hlp"        /* Help file name    */
  403. #define EMACSLOG    "emacs.log"        /* Log file name    */
  404. #define ERRORCMD    "error.cmd"        /* Error command file    */
  405. #endif
  406.  
  407. #if RISCOS    /* PROVISIONAL */
  408. #define EMACSRC        "EmacsRC"        /* Startup file name    */
  409. #define EMACSHLP    "EmacsHLP"        /* Help file name    */
  410. #define EMACSLOG    "EmacsLOG"        /* Log file name    */
  411. #define ERRORCMD    "Error"            /* Error command file    */
  412. #endif
  413.  
  414. #define    DRIVESEPCHAR    ':'
  415.  
  416. #if    VARARG
  417. #if    USG || BSD || SUN || XENIX || HPUX || AVIION || MPE
  418. #define    VARG    1
  419. #define    SARG    0
  420. #include    <varargs.h>
  421. #else
  422. #define    VARG    0
  423. #define    SARG    1
  424. #include    <stdarg.h>
  425. #endif
  426. #endif
  427.  
  428. /*    Emacs global flag bit definitions (for gflags)    */
  429.  
  430. #define GFREAD    1
  431.  
  432. /*    internal constants    */
  433.  
  434. #define NBINDS    300            /* max # of bound keys        */
  435. #if    AOSVS | VMS | RISCOS
  436. #define    NFILEN    256
  437. #else
  438. #define NFILEN    80            /* # of bytes, file name    */
  439. #endif
  440. #define NBUFN    32            /* # of bytes, buffer name    */
  441. #define NLINE    256            /* # of bytes, input line    */
  442. #define    NSTRING    128            /* # of bytes, string buffers    */
  443. #define NKBDM    256            /* # of strokes, keyboard macro */
  444. #define NPAT    128            /* # of bytes, pattern        */
  445. #define HUGE    1000            /* Huge number            */
  446. #define    NLOCKS    100            /* max # of file locks active    */
  447. #define    NCOLORS    16            /* number of supported colors    */
  448. #define    KBLOCK    250            /* sizeof kill buffer chunks    */
  449. #define    NBLOCK    16            /* line block chunk size    */
  450. #define    NVSIZE    10            /* max #chars in a var name    */
  451. #define NMARKS    10            /* number of marks        */
  452.  
  453. #define CTRL    0x0100        /* Control flag, or'ed in        */
  454. #define META    0x0200        /* Meta flag, or'ed in            */
  455. #define CTLX    0x0400        /* ^X flag, or'ed in            */
  456. #define SPEC    0x0800        /* special key (function keys)        */
  457. #define MOUS    0x1000        /* alternative input device (mouse)    */
  458. #define    SHFT    0x2000        /* shifted (for function keys)        */
  459. #define    ALTD    0x4000        /* ALT key...                */
  460.  
  461. #define    BINDNUL    0        /* not bount to anything        */
  462. #define    BINDFNC    1        /* key bound to a function        */
  463. #define    BINDBUF    2        /* key bound to a buffer        */
  464.  
  465. #ifdef    FALSE
  466. #undef    FALSE
  467. #endif
  468. #ifdef    TRUE
  469. #undef    TRUE
  470. #endif
  471.  
  472. #define FALSE    0            /* False, no, bad, etc.     */
  473. #define TRUE    1            /* True, yes, good, etc.    */
  474. #define ABORT    2            /* Death, ^G, abort, etc.    */
  475. #define    FAILED    3            /* not-quite fatal false return    */
  476.  
  477. #define STOP    0            /* keyboard macro not in use    */
  478. #define    PLAY    1            /*          playing    */
  479. #define    RECORD    2            /*          recording    */
  480.  
  481. /*    Competion types        */
  482.  
  483. #define    CMP_BUFFER    0
  484. #define    CMP_COMMAND    1
  485. #define    CMP_FILENAME    2
  486.  
  487. /*    Directive definitions    */
  488.  
  489. #define DIF        0
  490. #define DELSE        1
  491. #define DENDIF        2
  492. #define DGOTO        3
  493. #define DRETURN        4
  494. #define DENDM        5
  495. #define DWHILE        6
  496. #define    DENDWHILE    7
  497. #define    DBREAK        8
  498. #define DFORCE        9
  499.  
  500. #define NUMDIRS     10
  501.  
  502. /*
  503.  * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for
  504.  * the scan routines.
  505.  */
  506. #define PTBEG    0    /* Leave the point at the beginning on search    */
  507. #define    PTEND    1    /* Leave the point at the end on search        */
  508. #define    FORWARD    0            /* forward direction        */
  509. #define REVERSE    1            /* backwards direction        */
  510.  
  511. #define FIOSUC    0            /* File I/O, success.        */
  512. #define FIOFNF    1            /* File I/O, file not found.    */
  513. #define FIOEOF    2            /* File I/O, end of file.    */
  514. #define FIOERR    3            /* File I/O, error.        */
  515. #define    FIOMEM    4            /* File I/O, out of memory    */
  516. #define    FIOFUN    5            /* File I/O, eod of file/bad line*/
  517. #define    FIODEL    6            /* Can't delete/rename file    */
  518.  
  519. #define CFCPCN    0x0001            /* Last command was C-P, C-N    */
  520. #define CFKILL    0x0002            /* Last command was a kill    */
  521. #define    CFSRCH    0x0004            /* last command was a search    */
  522.  
  523. #define    SRNORM    0            /* end past, begin front    */
  524. #define    SRBEGIN    1            /* always at front        */
  525. #define    SREND    2            /* always one past end        */
  526.  
  527. #define BELL    0x07            /* a bell character        */
  528. #define    TAB    0x09            /* a tab character        */
  529.  
  530. #if    V7 | USG | SMOS | HPUX | BSD | SUN | XENIX | AVIION
  531. #define    PATHCHR    ':'
  532. #else
  533. #if    WMCS || MPE || RISCOS
  534. #define    PATHCHR ','
  535. #else
  536. #define PATHCHR ';'
  537. #endif
  538. #endif
  539.  
  540. #define INTWIDTH    sizeof(int) * 3
  541.  
  542. /*    Macro argument token types                    */
  543.  
  544. #define TKNUL    0            /* end-of-string        */
  545. #define    TKARG    1            /* interactive argument        */
  546. #define    TKBUF    2            /* buffer argument        */
  547. #define    TKVAR    3            /* user variables        */
  548. #define    TKENV    4            /* environment variables    */
  549. #define    TKFUN    5            /* function....            */
  550. #define    TKDIR    6            /* directive            */
  551. #define    TKLBL    7            /* line label            */
  552. #define    TKLIT    8            /* numeric literal        */
  553. #define    TKSTR    9            /* quoted string literal    */
  554. #define    TKCMD    10            /* command name            */
  555.  
  556. /*    Internal defined functions                    */
  557.  
  558. #define nextab(a)    (a - (a % tabsize)) + tabsize
  559.  
  560. /* DIFCASE represents the integer difference between upper
  561.    and lower case letters.  It is an xor-able value, which is
  562.    fortunate, since the relative positions of upper to lower
  563.    case letters is the opposite of ascii in ebcdic.
  564. */
  565.  
  566. #ifdef    islower
  567. #undef    islower
  568. #endif
  569. #ifdef    isupper
  570. #undef    isupper
  571. #endif
  572.  
  573. #if    ASCII
  574. #define    DIFCASE     0x20
  575. #else
  576. #define DIFCASE        0x40
  577. #endif
  578.  
  579. /* and keep the new sun compiler happy.... */
  580. /* and the Archimedes shared C library.... */
  581. #if    SUN | ARM
  582. #undef    isupper
  583. #undef    islower
  584. #define    isupper(a)    isucase(a)
  585. #define    islower(a)    islcase(a)
  586. #endif
  587.  
  588. /*    Dynamic RAM tracking and reporting redefinitions    */
  589.  
  590. #if    RAMSIZE
  591. #define    malloc    allocate
  592. #define    free    release
  593. #else
  594. #if    VMS & OPTMEM
  595. #define malloc     VAXC$MALLOC_OPT
  596. #define free    VAXC$FREE_OPT
  597. #define calloc    VAXC$CALLOC_OPT
  598. #define realloc VAXC$REALLOC_OPT
  599. #define cfree   VAXC$CFREE_OPT
  600. #endif
  601. #endif
  602.  
  603. /*
  604.  * There is a window structure allocated for every active display window. The
  605.  * windows are kept in a big list, in top to bottom screen order, with the
  606.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  607.  * The flag field contains some bits that are set by commands to guide
  608.  * redisplay. Although this is a bit of a compromise in terms of decoupling,
  609.  * the full blown redisplay is just too expensive to run for every input
  610.  * character.
  611.  */
  612. typedef struct    WINDOW {
  613.     struct    WINDOW *w_wndp;     /* Next window            */
  614.     struct    BUFFER *w_bufp;     /* Buffer displayed in window    */
  615.     struct    LINE *w_linep;        /* Top line in the window    */
  616.     struct    LINE *w_dotp;        /* Line containing "."        */
  617.     short    w_doto;         /* Byte offset for "."        */
  618.     struct    LINE *w_markp[NMARKS];    /* Line containing "mark"    */
  619.     short    w_marko[NMARKS];    /* Byte offset for "mark"    */
  620.     char    w_toprow;        /* Origin 0 top row of window    */
  621.     char    w_ntrows;        /* # of rows of text in window    */
  622.     char    w_force;        /* If NZ, forcing row.        */
  623.     char    w_flag;         /* Flags.            */
  624. #if    COLOR
  625.     char   w_fcolor;           /* current forground color      */
  626.     char    w_bcolor;        /* current background color    */
  627. #endif
  628.     int    w_fcol;         /* first column displayed    */
  629. }    WINDOW;
  630.  
  631. #define WFFORCE 0x01            /* Window needs forced reframe    */
  632. #define WFMOVE    0x02            /* Movement from line to line    */
  633. #define WFEDIT    0x04            /* Editing within a line    */
  634. #define WFHARD    0x08            /* Better to a full display    */
  635. #define WFMODE    0x10            /* Update mode line.        */
  636. #define    WFCOLR    0x20            /* Needs a color change        */
  637.  
  638. /*
  639.  *    This structure holds the information about each separate "screen"
  640.  * within the current editing session.  On a character based system, these
  641.  * screens overlay each other, and can individually be brought to front.
  642.  * On a windowing system like MicroSoft Windows 3.0, OS/2, the Macintosh,
  643.  * Intuition, Sunview or X-windows, each screen is represented in an OS
  644.  * window.  The terminolgy is wrong in emacs.....
  645.  *
  646.  *    EMACS        The outside World
  647.  *    screen        window
  648.  *    window        pane
  649.  */
  650.  
  651. typedef struct SCREEN {
  652.     struct SCREEN *s_next_screen;    /* link to next screen in list */
  653.     WINDOW *s_first_window;        /* head of linked list of windows */
  654.     WINDOW *s_cur_window;        /* current window in this screen */
  655.     char *s_screen_name;        /* name of the current window */
  656. } SCREEN;
  657.  
  658. /*
  659.  * Text is kept in buffers. A buffer header, described below, exists for every
  660.  * buffer in the system. The buffers are kept in a big list, so that commands
  661.  * that search for a buffer by name can find the buffer header. There is a
  662.  * safe store for the dot and mark in the header, but this is only valid if
  663.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  664.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  665.  * the header line in "b_linep"    Buffers may be "Inactive" which means the files associated with them
  666.  * have not been read in yet. These get read in at "use buffer" time.
  667.  */
  668. typedef struct    BUFFER {
  669.     struct    BUFFER *b_bufp;     /* Link to next BUFFER        */
  670.     struct    LINE *b_dotp;        /* Link to "." LINE structure    */
  671.     short    b_doto;         /* Offset of "." in above LINE    */
  672.     struct    LINE *b_markp[NMARKS];    /* The same as the above two,    */
  673.     short    b_marko[NMARKS];    /* but for the "mark"        */
  674.     int    b_fcol;            /* first col to display        */
  675.     struct    LINE *b_linep;        /* Link to the header LINE    */
  676.     struct    LINE *b_topline;    /* Link to narrowed top text    */
  677.     struct    LINE *b_botline;    /* Link to narrowed bottom text    */
  678.     char    b_active;        /* window activated flag    */
  679.     char    b_nwnd;         /* Count of windows on buffer    */
  680.     char    b_flag;         /* Flags            */
  681.     int    b_mode;            /* editor mode of this buffer    */
  682.     char    b_fname[NFILEN];    /* File name            */
  683.     char    b_bname[NBUFN];     /* Buffer name            */
  684. #if    CRYPT
  685.     char   b_key[NPAT];           /* current encrypted key        */
  686. #endif
  687. #if    FTYPE
  688.     int    b_type;            /* buffer file type        */
  689. #endif
  690. }    BUFFER;
  691.  
  692. #define BFINVS    0x01            /* Internal invisable buffer    */
  693. #define BFCHG    0x02            /* Changed since last write    */
  694. #define    BFTRUNC    0x04            /* buffer was truncated when read */
  695. #define    BFNAROW    0x08            /* buffer has been narrowed    */
  696.  
  697. /*    mode flags    */
  698. #define    NUMMODES    10           /* # of defined modes           */
  699.  
  700. #define MDWRAP    0x0001            /* word wrap            */
  701. #define    MDCMOD    0x0002            /* C indentation and fence match*/
  702. #define    MDSPELL    0x0004            /* spell error parsing        */
  703. #define    MDEXACT    0x0008            /* Exact matching for searches    */
  704. #define    MDVIEW    0x0010            /* read-only buffer        */
  705. #define MDOVER    0x0020            /* overwrite mode        */
  706. #define MDMAGIC    0x0040            /* regular expresions in search */
  707. #define    MDCRYPT    0x0080            /* encrytion mode active    */
  708. #define    MDASAVE    0x0100            /* auto-save mode        */
  709. #define    MDREPL    0x0200            /* replace mode            */
  710.  
  711. /*
  712.  * The starting position of a region, and the size of the region in
  713.  * characters, is kept in a region structure.  Used by the region commands.
  714.  */
  715. typedef struct    {
  716.     struct    LINE *r_linep;        /* Origin LINE address.     */
  717.     short    r_offset;        /* Origin LINE offset.        */
  718.     long    r_size;         /* Length in characters.    */
  719. }    REGION;
  720.  
  721. /*
  722.  * All text is kept in circularly linked lists of "LINE" structures. These
  723.  * begin at the header line (which is the blank line beyond the end of the
  724.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  725.  * number of bytes in the line (the "used" size), the size of the text array,
  726.  * and the text. The end of line is not stored as a byte; it's implied.
  727.  */
  728. typedef struct    LINE {
  729.     struct    LINE *l_fp;        /* Link to the next line    */
  730.     struct    LINE *l_bp;        /* Link to the previous line    */
  731.     short    l_size;         /* Allocated size        */
  732.     short    l_used;         /* Used size            */
  733.     char    l_text[1];        /* A bunch of characters.    */
  734. }    LINE;
  735.  
  736. #define lforw(lp)    ((lp)->l_fp)
  737. #define lback(lp)    ((lp)->l_bp)
  738. #define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  739. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  740. #define llength(lp)    ((lp)->l_used)
  741.  
  742. /*
  743.  * The editor communicates with the display using a high level interface. A
  744.  * "TERM" structure holds useful variables, and indirect pointers to routines
  745.  * that do useful operations. The low level get and put routines are here too.
  746.  * This lets a terminal, in addition to having non standard commands, have
  747.  * funny get and put character code too. The calls might get changed to
  748.  * "termp->t_field" style in the future, to make it possible to run more than
  749.  * one terminal type.
  750.  */
  751. typedef struct    {
  752.     short    t_mrow;          /* max number of rows allowable */
  753.     short    t_nrow;         /* current number of rows used    */
  754.     short    t_mcol;         /* max Number of columns.    */
  755.     short    t_ncol;         /* current Number of columns.    */
  756.     short    t_margin;        /* min margin for extended lines*/
  757.     short    t_scrsiz;        /* size of scroll region "    */
  758.     int    t_pause;        /* # times thru update to pause */
  759.     int (PASCAL NEAR *t_open)();    /* Open terminal at the start.    */
  760.     int (PASCAL NEAR *t_close)();    /* Close terminal at end.    */
  761.     int (PASCAL NEAR *t_kopen)();    /* Open keyboard        */
  762.     int (PASCAL NEAR *t_kclose)();    /* close keyboard        */
  763.     int (PASCAL NEAR *t_getchar)(); /* Get character from keyboard. */
  764.     int (PASCAL NEAR *t_putchar)(); /* Put character to display.    */
  765.     int (PASCAL NEAR *t_flush)();    /* Flush output buffers.    */
  766.     int (PASCAL NEAR *t_move)();    /* Move the cursor, origin 0.    */
  767.     int (PASCAL NEAR *t_eeol)();    /* Erase to end of line.    */
  768.     int (PASCAL NEAR *t_eeop)();    /* Erase to end of page.    */
  769.     int (PASCAL NEAR *t_beep)();    /* Beep.            */
  770.     int (PASCAL NEAR *t_rev)();    /* set reverse video state    */
  771.     int (PASCAL NEAR *t_rez)();    /* change screen resolution    */
  772. #if    COLOR
  773.     int (PASCAL NEAR *t_setfor)();     /* set forground color        */
  774.     int (PASCAL NEAR *t_setback)();    /* set background color        */
  775. #endif
  776. #if    INSDEL
  777.     int (PASCAL NEAR *t_insline)();    /* insert a screen line        */
  778.     int (PASCAL NEAR *t_delline)();    /* delete a screen line        */
  779. #endif
  780. }    TERM;
  781.  
  782. /*    TEMPORARY macros for terminal I/O  (to be placed in a machine
  783.                         dependant place later) */
  784.  
  785. #define TTopen        (*term.t_open)
  786. #define    TTclose        (*term.t_close)
  787. #define    TTkopen        (*term.t_kopen)
  788. #define    TTkclose    (*term.t_kclose)
  789. #define    TTgetc        (*term.t_getchar)
  790. #define    TTputc        (*term.t_putchar)
  791. #define    TTflush        (*term.t_flush)
  792. #define    TTmove        (*term.t_move)
  793. #define    TTeeol        (*term.t_eeol)
  794. #define    TTeeop        (*term.t_eeop)
  795. #define    TTbeep        (*term.t_beep)
  796. #define    TTrev        (*term.t_rev)
  797. #define    TTrez        (*term.t_rez)
  798. #if    COLOR
  799. #define    TTforg        (*term.t_setfor)
  800. #define    TTbacg        (*term.t_setback)
  801. #endif
  802.  
  803. /*    Structure for the table of current key bindings     */
  804.  
  805. ETYPE EPOINTER {
  806.     int (PASCAL NEAR *fp)();    /* C routine to invoke */
  807.     BUFFER *buf;            /* buffer to execute */
  808. };
  809.  
  810. typedef struct    {
  811.     short k_code;         /* Key code            */
  812.     short k_type;        /* binding type (C function or EMACS buffer) */
  813.     ETYPE EPOINTER k_ptr;    /* ptr to thing to execute */
  814. }    KEYTAB;
  815.  
  816. /*    structure for the name binding table        */
  817.  
  818. typedef struct {
  819.     char *n_name;            /* name of function key */
  820.     int (PASCAL NEAR *n_func)();    /* function name is bound to */
  821. }    NBIND;
  822.  
  823. /*    The editor holds deleted text chunks in the KILL buffer. The
  824.     kill buffer is logically a stream of ascii characters, however
  825.     due to its unpredicatable size, it gets implemented as a linked
  826.     list of chunks. (The d_ prefix is for "deleted" text, as k_
  827.     was taken up by the keycode structure)
  828. */
  829.  
  830. typedef struct KILL {
  831.     struct KILL *d_next;   /* link to next chunk, NULL if last */
  832.     char d_chunk[KBLOCK];    /* deleted text */
  833. } KILL;
  834.  
  835. /*    When emacs' command interpetor needs to get a variable's name,
  836.     rather than it's value, it is passed back as a VDESC variable
  837.     description structure. The v_num field is a index into the
  838.     appropriate variable table.
  839. */
  840.  
  841. typedef struct VDESC {
  842.     int v_type;    /* type of variable */
  843.     int v_num;    /* ordinal pointer to variable in list */
  844. } VDESC;
  845.  
  846. /*    The !WHILE directive in the execution language needs to
  847.     stack references to pending whiles. These are stored linked
  848.     to each currently open procedure via a linked list of
  849.     the following structure
  850. */
  851.  
  852. typedef struct WHBLOCK {
  853.     LINE *w_begin;        /* ptr to !while statement */
  854.     LINE *w_end;        /* ptr to the !endwhile statement*/
  855.     int w_type;        /* block type */
  856.     struct WHBLOCK *w_next;    /* next while */
  857. } WHBLOCK;
  858.  
  859. #define BTWHILE     1
  860. #define    BTBREAK        2
  861.  
  862.  
  863. /* HICHAR - 1 is the largest character we will deal with.
  864.  * HIBYTE represents the number of bytes in the bitmap.
  865.  */
  866. #define HICHAR        256
  867. #define    HIBYTE        HICHAR >> 3
  868.  
  869. #if    MAGIC
  870. /*
  871.  * Defines for the metacharacters in the regular expression
  872.  * search routines.
  873.  */
  874. #define MCNIL        0    /* Like the '\0' for strings.*/
  875. #define    LITCHAR        1    /* Literal character, or string.*/
  876. #define    ANY        2
  877. #define    CCL        3
  878. #define    NCCL        4
  879. #define    BOL        5
  880. #define    EOL        6
  881. #define    DITTO        7
  882. #define    CLOSURE        0x0100    /* An or-able value for a closure modifier.*/
  883. #define    CLOSURE_1    0x0200    /* An or-able value for a closure modifier.*/
  884. #define    ZEROONE        0x0400    /* An or-able value for a closure modifier.*/
  885. #define    GRPBEG        0x1000    /* An or-able value.*/
  886. #define    GRPEND        0x2000    /* An or-able value.*/
  887.  
  888. #define ALLCLOS        (CLOSURE | CLOSURE_1 | ZEROONE)
  889. #define    MASKCLO        0x00ff
  890.  
  891. #define MC_ANY        '.'    /* 'Any' character (except newline).*/
  892. #define    MC_CCL        '['    /* Character class.*/
  893. #define    MC_NCCL        '^'    /* Negate character class.*/
  894. #define    MC_RCCL        '-'    /* Range in character class.*/
  895. #define    MC_ECCL        ']'    /* End of character class.*/
  896. #define    MC_BOL        '^'    /* Beginning of line.*/
  897. #define    MC_EOL        '$'    /* End of line.*/
  898. #define    MC_CLOSURE    '*'    /* Closure - zero to many characters match.*/
  899. #define    MC_CLOSURE_1    '+'    /* Closure - one to many characters match.*/
  900. #define    MC_ZEROONE    '?'    /* Closure - zero to one characters match.*/
  901. #define    MC_DITTO    '&'    /* Use matched string in replacement.*/
  902. #define MC_GRPBEG    '{'    /* Start of group.*/
  903. #define MC_GRPEND    '}'    /* End of group.*/
  904. #define    MC_ESC        '\\'    /* Escape - suppress meta-meaning.*/
  905.  
  906. #define MAXGROUPS    10        /* 1 + maximum # of r. e. groups. */
  907. #define BIT(n)        (1 << (n))    /* An integer with one bit set.*/
  908.  
  909. /* Typedefs that define the bitmap type for searching (BITMAP),
  910.  * the meta-character structure for MAGIC mode searching (MC),
  911.  * and the meta-character structure for MAGIC mode replacment (RMC).
  912.  */
  913. typedef char    *BITMAP;
  914.  
  915. typedef struct {
  916.     short int    mc_type;
  917.     short int    group_no;
  918.     union {
  919.         int    lchar;
  920.         BITMAP    cclmap;
  921.     } u;
  922. } MC;
  923.  
  924. typedef struct {
  925.     short int      mc_type;
  926.     char    *rstr;
  927. } RMC;
  928. #endif
  929.  
  930. /*
  931.     This is the message which should be added to any "About MicroEMACS"
  932.     boxes on any of the machines with window managers.
  933.  
  934.  
  935.     ------------------------------------------
  936.     |                     |
  937.     |     MicroEMACS v3.xx         |
  938.     |        for the ............     |
  939.     |                     |
  940.     |    Text Editor and Corrector         |
  941.     |                     |
  942.     |    written by Daniel M. Lawrence     |
  943.     |    [based on code by Dave Conroy]     |
  944.     |                     |
  945.     |    Send inquiries and donations to:     |
  946.     |    617 New York St             |
  947.     |    Lafayette, IN 47901         |
  948.     |                     |
  949.     ------------------------------------------
  950. */
  951.